package com.tran.app.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.tran.app.data.UserPlane
import kotlinx.coroutines.flow.Flow

@Dao
interface UserPlaneDao {
    @Insert
    fun insertUserPlane(userPlane: UserPlane): Long

    @Update
    fun updateUserPlane(userPlane: UserPlane): Int

    @Delete
    fun deleteUserPlane(userPlane: UserPlane): Int

    @Query("SELECT * FROM UserPlane")
    fun getAllUserPlanes(): List<UserPlane>

    @Query("SELECT * FROM UserPlane WHERE id = :id")
    fun getUserPlaneById(id: Int): Flow<UserPlane?>

    @Query("SELECT * FROM UserPlane WHERE username = :name")
    fun getUserPlaneByName(name: String): Flow<List<UserPlane?>>
}